

package com.mt.restaurant.controller.sale;

import org.springframework.security.access.prepost.PreAuthorize;
import com.mt.common.core.annotation.ApiPageParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.mt.common.core.web.base.PageDTO;
import com.mt.common.core.web.base.PageResultDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;



import com.mt.restaurant.dto.sale.PaymentRecordEditDto;
import com.mt.restaurant.entity.sale.PaymentRecord;
import com.mt.restaurant.service.sale.PaymentRecordService;
											

@Api(tags = "付款记录")
@RestController
@RequestMapping("/api/restaurant/sale/PaymentRecord")
@CrossOrigin(allowCredentials = "true")
public class PaymentRecordController {
private static Logger logger = LoggerFactory.getLogger(PaymentRecordController.class);



																																				@Autowired private PaymentRecordService paymentRecordService;
	
	/**
	* 根据分页参数查询付款记录集合
	*
	* @param pageDTO 分页条件
	*/
	@PreAuthorize("hasAuthority('restaurant:sale:PaymentRecord:view')")
	@ApiOperation("分页查询付款记录")
	@ApiPageParam
	@PostMapping("/findPaymentRecords")
	public PageResultDTO findPaymentRecords(@RequestBody PageDTO pageDTO){
		return this.paymentRecordService.findPaymentRecords(pageDTO);
	}

	/**
	* 根据ID查询指定的付款记录
	*
	* @param paymentRecordId Id
	*/
	@PreAuthorize("hasAuthority('restaurant:sale:PaymentRecord:view')")
	@ApiOperation("根据id查询付款记录")
	@ApiPageParam
	@PostMapping("/findPaymentRecord")
	public PaymentRecord findPaymentRecord(@RequestParam Long paymentRecordId){
		return this.paymentRecordService.findPaymentRecord(paymentRecordId);
	}

	/**
	* 根据ID查询指定的付款记录(包含外键名称)
	*
	* @param paymentRecordId Id
	*/
	@PreAuthorize("hasAuthority('restaurant:sale:PaymentRecord:view')")
	@ApiOperation("根据ID查询指定的付款记录(包含外键名称)")
	@PostMapping("/findPaymentRecordForView")
	public PaymentRecord findPaymentRecordForView(@RequestParam Long paymentRecordId){
		return this.paymentRecordService.findPaymentRecordWithForeignName(paymentRecordId);
	}

	/**
	* 根据ID查询指定的付款记录(包含付款记录和外键名称)
	*
	* @param paymentRecordId Id
	*/
	@PreAuthorize("hasAuthority('restaurant:sale:PaymentRecord:view')")
	@ApiOperation("根据ID查询指定的付款记录(包含付款记录和外键名称)")
	@PostMapping("/findPaymentRecordForEdit")
	public PaymentRecordEditDto findPaymentRecordForEdit(@RequestParam Long paymentRecordId){
				PaymentRecordEditDto paymentRecordEditDto = new PaymentRecordEditDto();
		paymentRecordEditDto.setPaymentRecord(this.paymentRecordService.findPaymentRecordWithForeignName(paymentRecordId));

		this.preparePaymentRecordEditDto(paymentRecordEditDto);

		return paymentRecordEditDto;
	}

	/**
	* 根据ID查询指定的付款记录(只提取ID 和 Name)
	*
	* @param paymentRecordId Id
	*/
	@PreAuthorize("hasAuthority('restaurant:sale:PaymentRecord:view')")
	@ApiOperation("根据ID查询指定的付款记录(只提取ID 和 Name)")
	@PostMapping("/findPaymentRecordsWithIdNameById")
	public PaymentRecord findPaymentRecordsWithIdNameById(@RequestParam Long paymentRecordId){
	return this.paymentRecordService.findPaymentRecordsWithIdNameById(paymentRecordId);
	}

	/**
	* 根据名称查询付款记录集合(只提取ID 和 Name)
	*
	* @param paymentRecordName 名称
	*/
	@PreAuthorize("hasAuthority('restaurant:sale:PaymentRecord:view')")
	@ApiOperation("根据名称查询付款记录集合(只提取ID 和 Name)")
	@PostMapping("/findPaymentRecordsWithIdNameByName")
	public List<PaymentRecord> findPaymentRecordsWithIdNameByName(@RequestParam String paymentRecordName){
	return this.paymentRecordService.findPaymentRecordsWithIdNameByName(paymentRecordName);
	}


	/**
	* 创建新的付款记录
	*
	*/
	@PreAuthorize("hasAuthority('restaurant:sale:PaymentRecord:add')")
	@ApiOperation("创建新的付款记录")
	@PostMapping("/createPaymentRecord")
	public PaymentRecordEditDto createPaymentRecord(){
				PaymentRecordEditDto paymentRecordEditDto = new PaymentRecordEditDto();
		paymentRecordEditDto.setPaymentRecord(new PaymentRecord());

		this.preparePaymentRecordEditDto(paymentRecordEditDto);
		return paymentRecordEditDto;
	}

	private void preparePaymentRecordEditDto(PaymentRecordEditDto paymentRecordEditDto){
																																			}

	/**
	* 新增保存付款记录
	*
	* @param paymentRecord 实体对象
	*/
	@PreAuthorize("hasAuthority('restaurant:sale:PaymentRecord:add')")
	@ApiOperation("新增保存付款记录")
	@PostMapping("/savePaymentRecord")
	public PaymentRecord savePaymentRecord(@RequestBody PaymentRecord paymentRecord){
		return this.paymentRecordService.savePaymentRecord(paymentRecord);
	}

	/**
	* 修改保存付款记录
	*
	* @param paymentRecord 实体对象
	*/
	@PreAuthorize("hasAuthority('restaurant:sale:PaymentRecord:update')")
	@ApiOperation("修改保存付款记录")
	@PostMapping("/updatePaymentRecord")
	public PaymentRecord updatePaymentRecord(@RequestBody PaymentRecord paymentRecord){
		return this.paymentRecordService.updatePaymentRecord(paymentRecord);
	}

	/**
	* 根据ID删除付款记录
	*
	* @param paymentRecordId ID
	*/
	@PreAuthorize("hasAuthority('restaurant:sale:PaymentRecord:remove')")
	@ApiOperation("根据ID删除付款记录")
	@PostMapping("/deletePaymentRecord")
	public void deletePaymentRecord(@RequestParam Long paymentRecordId){
		this.paymentRecordService.deletePaymentRecord(paymentRecordId);
	}



}

